/* 
 * File:   Loader.h
 * Author: Lukas Gemela
 *
 * Created on 11. listopad 2012, 8:44
 */

#ifndef LOADER_H
#define	 LOADER_H
#define BG_VALUE "BG"
#define IG_VALUE "IG"
#define DELITIMIER_VALUE ';'
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include "DataSet.h"
#include "TimeUtils.h"
#include "StringUtils.h"

using namespace std;

class Loader {
public:
    Loader(string filename);
    Loader(const Loader& orig);
    bool load();
    virtual ~Loader();

    shared_ptr<IFastDataApprox> getIGValues() const {
        return p_IGValues;
    }

    shared_ptr<IFastDataApprox> getBGValues() const {
        return p_BGValues;
    }
private:
    string filename;
    shared_ptr<DataSet> p_IGValues;
    shared_ptr<DataSet> p_BGValues;
    const string BG;// = BG_VALUE;
    const string IG;// = IG_VALUE;
    const char DELIMITIER;// = ';';

    vector<string> split(const string &s, char delim);
    void findColumnsIndex(vector<string>, int *BGIndex, int *IGIndex);
    void csvline_populate(vector<string> &record, const string& line, char delimiter);
    bool loadFileToVector(vector<string> &rows);
    DataSet parseLines(vector<string> &rows);
    DataSet transformToDataSet(vector<string> &rows, int BGIndex, int IGIndex);
};

#endif	/* LOADER_H */

